<template>
	<div class="app-container">
		<div class="header">{{ detail.documentTitle }}</div>
		<div class="tip">更新日期：{{ detail.updateTime }}&nbsp;&nbsp;&nbsp;浏览量：{{ detail.viewCount }}</div>
		<div class="row-header">附件</div>
		<div class="info-url" v-for="item in detail.filePaths" :key="item" @click="downloadFile(item)">
			<el-icon style="position: relative; top: 3px"><Link /></el-icon>&nbsp;{{ item }}
		</div>
		<div class="row-header" style="margin-bottom: 10px">图片预览</div>
		<el-image style="width: 100px; height: 100px;margin-right: 10px;" v-for="item in detail.imgPaths" :key="item" :src="pre+item" fit="fill" :preview-src-list="[pre+item]" />
		<div class="row-header">内容描述</div>
		<div v-html="detail.documentContent"></div>
		<div style="line-height: 80px; height: 80px; padding-left: 35%; margin-top: 20px">
			<el-button @click="reback">返回</el-button>
		</div>
	</div>
</template>
<script setup>
import { useRoute } from 'vue-router'
import { download } from '@/utils/request'
import { getDocument } from '@/api/tank/tank'
import { getConfigKey } from '@/api/system/config'
import useTagsViewStore from '@/store/modules/tagsView'
const tagsView = useTagsViewStore()
const pre = ref('')
getConfigKey('sys.upload').then((response) => {
	pre.value = response.msg
	if (route.query.id) {
		getDocument({ documentId: route.query.id }).then((res) => {
			detail.value = res.data
		})
	}
})
const route = useRoute()
const router = useRouter()
const detail = ref({})

const downloadFile = (file) => {
	download({ url: file }).then()
}
const reback = () => {
	tagsView.delView(router.currentRoute.value)
router.go(-1)
}
</script>
<style lang="scss" scoped>
.app-container {
	// width: 50% !important;
}
.header {
	font-size: 24px;
	color: black;
	font-weight: 600;
	text-align: center;
	height: 50px;
	line-height: 50px;
}
.tip {
	height: 50px;
	line-height: 50px;
	font-size: 14px;
	text-align: center;
	background-color: rgb(231, 231, 231);
}
.row-header {
	font-weight: 600;
	height: 50px;
	line-height: 50px;
	border-bottom: 2px rgba(240, 240, 240, 1) solid;
	border-top: 2px rgba(240, 240, 240, 1) solid;
	margin-top: 10px;
}
.info-url {
	height: 40px;
	line-height: 40px;
	font-size: 18px;
	background-color: #3f9efe;
	color: #ffffff;
	margin: 10px 0;
	padding-left: 10px;
	cursor: pointer;
}
</style>
